<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div>发送验证码：</div>
    <input type="number" />
    <button>点击发送验证码</button>
  </body>
  <script>
    var buttonDom = document.querySelector("button");

    var time = 60;
    buttonDom.onclick = function () {
      buttonDom.disabled = true;
      console.log("触发点击事件,发送验证码");
      buttonDom.innerText = time;
      var interval = setInterval( function () {
        time--;
        console.log(time);
        buttonDom.innerText = time;
        if (time == 0) {
          buttonDom.disabled = false;
          buttonDom.innerText = "点击发送验证码";
          time = 60;
          clearInterval(interval);
        }
      }, 1000);
    };
  </script>
</html>
